package com.leetcode.partition1;

import java.io.*;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Stack;

/**
 * @author `RKC`
 * @date 2022/1/6 9:15
 */
public class LC71简化路径 {

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String s = reader.readLine();
        writer.write(simplifyPath(s));
        writer.flush();
    }

    public static String simplifyPath(String path) {
        Stack<String> stack = new Stack<>();
        stack.push("/");
        String[] s = path.split("/+");
        for (int i = 1; i < s.length; i++) {
            if ("..".equals(s[i])) {
                if (!stack.isEmpty()) stack.pop();
            }
            else if (".".equals(s[i])) continue;
            else stack.push(s[i]);
        }
        StringBuilder sb = new StringBuilder();
        s = new String[stack.size()];
        int i = 0;
        while (!stack.isEmpty()) s[i++] = stack.pop();
        for (int j = 0; j < s.length / 2; j++) {
            String temp = s[j];
            s[j] = s[s.length - j - 1];
            s[s.length - j - 1] = temp;
        }
        for (int j = 0; j < s.length; j++) {
            sb.append(s[j]);
            if (!s[j].equals("/")) sb.append("/");
        }
        if (sb.length() > 1) sb.deleteCharAt(sb.length() - 1);
        if (sb.length() == 0) sb.append("/");
        if (sb.charAt(0) != '/') sb.insert(0, '/');
        return sb.toString();
    }
}
